define(function(require, exports){
	// 广告主管理列表
	exports.onMain = function(boot,data,app){
		if (!app.routerValid('agent.qualification')) {
			return;
		}
		var title = LANG('广告主管理');
		var con = app.getContainer({
			scenes: 'main',
			full: false,
			sitelist: false,
			setup_btn: false,
			title: title,
			type: 'sidebar'
		});

		// app.core.get('SYS_PLATFORM').setPlatform(title);
		con.createBusiness(data.name  + '_bar', 'layout/navbar.base', {
			'contentType': 'info',
			'autoBuild': true,
			'data': data,
			'addTitle': title,
			'type': 'admin'
		}, function(mod, created){
			if(mod){
				mod.setData(data, title);
			}
		});

		con.createBusiness(data.name, 'admin/aptitude/action/list.main',null, function(mod,notFirst){
			if(notFirst){
				mod.reload();
			}
		});
	};

	// 广告主审核详情列表
	exports.onVerify = function(boot,data,app){
		if (!app.routerValid('qualification.list')) {
			return;
		}

		var title = LANG(' 审核详情');

		var con = app.getContainer({
			scenes: 'main',
			full: false,
			sitelist: false,
			setup_btn: false,
			title: title,
			type: 'sidebar'
		});

		con.createBusiness(data.name  + '_bar', 'layout/navbar.base', {
			'contentType': 'info',
			'autoBuild': true,
			'data': data,
			'addTitle': title,
			'type': ''
		}, function(mod, created){
			if(mod){
				mod.setData(data, title);
			}
		});

		con.createBusiness(data.name, 'admin/aptitude/action/verifyList.main');
	};

	// 新建广告主
	exports.onEdit = function(boot,data,app){
		var id = +data.param;
		var title = id ? LANG("编辑广告主") : LANG("新建广告主");
		var right = id ? 'qualification.update' : 'qualification.add';
		if (!app.routerValid(right)) {
			return;
		}
		var con = app.getContainer({
			scenes: 'main',
			full: false,
			sitelist: false,
			setup_btn: false,
			title: title,
			type: 'scroll'
		});

		con.createBusiness(data.name  + '_bar', 'layout/navbar.base', {
			'contentType': 'info',
			'autoBuild': true,
			'data': data,
			'addTitle': title,
			'type': ""
		}, function(mod, created){
			if(mod){
				mod.setData(data, title);
			}
		});

		con.createBusiness(data.name, 'admin/aptitude/action/edit.main', {}, function(mod, created) {
			if(created){
				mod.reset();
			}
			if (id) {
				mod.setParam({
					'_id': +id
				}).load();
			}
		})
	};
});